package com.easy.dn.ui.main.activity;

import android.widget.EditText;

import com.easy.common.base.BaseActivity;
import com.easy.common.baserx.RxSubscriber;
import com.easy.common.commonwidget.DnToolbar;
import com.easy.common.commonwidget.RippleView;
import com.easy.dn.api.Api;
import com.easy.dn.api.ApiService;
import com.easy.dn.bean.HomeBean;
import com.easy.dn.utils.MapHelper;

import java.util.Map;

import butterknife.Bind;
import butterknife.OnClick;
import dn.easy.com.easyto.R;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * ░░░░░░░░░░░░░░░░░░░░░░░░▄░░
 * ░░░░░░░░░▐█░░░░░░░░░░░▄▀▒▌░
 * ░░░░░░░░▐▀▒█░░░░░░░░▄▀▒▒▒▐
 * ░░░░░░░▐▄▀▒▒▀▀▀▀▄▄▄▀▒▒▒▒▒▐
 * ░░░░░▄▄▀▒░▒▒▒▒▒▒▒▒▒█▒▒▄█▒▐
 * ░░░▄▀▒▒▒░░░▒▒▒░░░▒▒▒▀██▀▒▌
 * ░░▐▒▒▒▄▄▒▒▒▒░░░▒▒▒▒▒▒▒▀▄▒▒
 * ░░▌░░▌█▀▒▒▒▒▒▄▀█▄▒▒▒▒▒▒▒█▒▐
 * ░▐░░░▒▒▒▒▒▒▒▒▌██▀▒▒░░░▒▒▒▀▄
 * ░▌░▒▄██▄▒▒▒▒▒▒▒▒▒░░░░░░▒▒▒▒
 * ▀▒▀▐▄█▄█▌▄░▀▒▒░░░░░░░░░░▒▒▒
 * 单身狗就这样默默地看着你，一句话也不说。
 * <p>
 * 意见反馈
 * @author DN
 * @data 2017/7/27
 **/
public class FeedbackActivity extends BaseActivity {

    @Bind(R.id.toolbar)
    DnToolbar mToolbar;
    @Bind(R.id.ed_feedback)
    EditText mFeedback;
    @Bind(R.id.commonBtn)
    RippleView mCommonBtn;

    @Override
    public int getLayoutId() {
        return R.layout.act_feedback;
    }

    @Override
    public void initPresenter() {
        initTitle();
        mToolbar.setMainTitle(R.string.user_feedback);
    }

    @Override
    public void initView() {
    }

    @OnClick(R.id.commonBtn)
    public void onViewClicked() {
        if (mFeedback.getText().toString().trim().length()>0){
            Map<String, String> map = MapHelper.getAccessMap();
            map.put("type","3");
            map.put("content",mFeedback.getText().toString());
            map.put("add","");
            Api.getInstance().getProxy(ApiService.class)
                    .uploadFeedBackData(Api.getCacheControl(),map)
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribe(new RxSubscriber<HomeBean>(mContext,true) {
                @Override
                protected void _onNext(HomeBean homeBean) {
                    showShortToast(mContext.getResources().getString(R.string.thinkyou_information_feedbacked));
                    finish();
                }

                @Override
                protected void _onError(String message) {
//                    DnUtils.showToast(mFeedback,mContext.getResources().getString(R.string.sorry_try_again));
                    showShortToast(mContext.getResources().getString(R.string.sorry_try_again));
                }
            });
        }else {
            showShortToast(mContext.getResources().getString(R.string.feedback_p));
        }
    }
}
